<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page import="net.tribal.comic.entities.User" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title><g:message code="user.edit" default="EDIT USER" /></title>
    </head>
    <body>
    	<div class="nav">
            <span class="menuButton"><g:link class="create" action="create"><g:message code="user.new" default="NEW USER" /></g:link></span>
        </div>
        
        <h1><g:message code="user.edit" default="EDIT USER" /></h1>

		<g:form action="update">
			<div class="roundedCorners wrapper dialog">
	
				<g:hasErrors bean="${userInstance}"><div class="errors"><g:renderErrors bean="${userInstance}" as="list" /></div></g:hasErrors>

		    	<table>
        			<tbody>
    			    	<tr class="prop">
                        	<td valign="top" class="name">
                                <label for="alias"><g:message code="user.alias" default="Alias" />:</label>
                            </td>
                            <td colspan="2" valign="top" class="value ${hasErrors(bean: userInstance, field: 'alias', 'errors')}">
                                <g:textField name="alias" value="${fieldValue(bean: userInstance, field: 'alias')}" />
                            </td>
                            <td valign="top" class="name">
                                <label for="email"><g:message code="user.email" default="Email" />:</label>
                            </td>
                            <td colspan="2" valign="top" class="value ${hasErrors(bean: userInstance, field: 'email', 'errors')}">
                                <g:textField name="email" value="${fieldValue(bean: userInstance, field: 'email')}" />
                            </td>
                        </tr>
    			
            			<tr class="prop">
		                	<td valign="top" class="name">
		                    	<label for="name"><g:message code="user.name" default="Name" />:</label>
		                    </td>
                            <td colspan="2" valign="top" class="value ${hasErrors(bean: userInstance, field: 'name', 'errors')}">
                                <g:textField name="name" class="focus" value="${fieldValue(bean: userInstance, field: 'name')}" />
                            </td>
                            <td valign="top" class="name">
                                <label for="lastName"><g:message code="user.lastName" default="Last Name" />:</label>
                            </td>
                            <td colspan="2" valign="top" class="value ${hasErrors(bean: userInstance, field: 'lastName', 'errors')}">
                                <g:textField name="lastName" value="${fieldValue(bean: userInstance, field: 'lastName')}" />
                            </td>
                        </tr>
                        
                        <tr class="prop">
                            <td valign="top" class="name">
                                <label for="gender"><g:message code="user.gender" default="Gender" />:</label>
                            </td>
                            <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'gender', 'errors')}">
                                <g:textField name="gender" value="${fieldValue(bean: userInstance, field: 'gender')}" />
                            </td>
                            <td valign="top" class="name">
                                <label for="birdDay"><g:message code="user.birdDay" default="Bird Day" />:</label>
                            </td>
                            <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'birdDay', 'errors')}">
                                <g:datePicker name="birdDay" value="${userInstance?.birdDay}" precision="day" />
                            </td>
                            <td valign="top" class="name">
                                <label for="country"><g:message code="user.country" default="Country" />:</label>
                            </td>
                            <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'country', 'errors')}">
                    			<g:textField name="country" value="${fieldValue(bean: userInstance, field: 'country')}" />
                    		</td>
                        </tr>
                        
                        <tr class="prop">
                            <td valign="top" class="name">
                                <label for="disabled"><g:message code="user.disabled" default="Disabled" />:</label>
                            </td>
                            <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'disabled', 'errors')}">
                                <g:checkBox name="disabled" value="${userInstance?.disabled}" />
                            </td>
                            <td valign="top" class="name">
                                <label for="commentable"><g:message code="user.commentable" default="Commentable" />:</label>
                            </td>
                            <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'commentable', 'errors')}">
                                <g:checkBox name="commentable" value="${userInstance?.commentable}" />
                            </td>
                            <td valign="top" class="name">
                                <label for="rateable"><g:message code="user.rateable" default="Rateable" />:</label>
                            </td>
                            <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'rateable', 'errors')}">
                                <g:checkBox name="rateable" value="${userInstance?.rateable}" />
                            </td>
                        </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="favoritesComics"><g:message code="user.favoritesComics" default="Favorites Comics" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'favoritesComics', 'errors')}">
                                    
<ul>
<g:each in="${userInstance?.favoritesComics}" var="comicInstance">
    <li><g:link controller="comic" action="show" id="${comicInstance.id}">${comicInstance?.encodeAsHTML()}</g:link></li>
</g:each>
</ul>
<g:link controller="comic" params="['user.id': userInstance?.id]" action="create"><g:message code="comic.new" default="New Comic" /></g:link>


                                </td>
                            </tr>
                        
        	</tbody>
        </table>
           
        <g:link controller="comment" params="['user.id': userInstance?.id]" action="create"><g:message code="comment.new" default="New Comment" /></g:link>
        
    	<div class="buttons">
    		<span class="button"><g:actionSubmit class="show" action="show" value="${message(code: 'show', 'default': 'SHOW')}" /></span>
        	<span class="button"><g:actionSubmit class="save" action="updateProfile" value="${message(code: 'update', 'default': 'UPDATE PROFILE')}" /></span>
    	</div>
    </div>
	<g:hiddenField name="id" value="${userInstance?.id}" />
	<g:hiddenField name="version" value="${userInstance?.version}" />
</g:form>

</body>
</html>
